package com.itzhigui.service.impl;

import com.itzhigui.entity.Student2;
import com.itzhigui.mapper.Student2Mapper;
import com.itzhigui.service.Student2Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author java1412
 * @since 2023-11-08 11:08:12
 */
@Service
@Transactional
public class Student2ServiceImpl implements Student2Service {

    @Resource
    private Student2Mapper student2Mapper;

    @Override
    public Map<String, Object> findAll() {
        List<Student2> studentList = student2Mapper.findAll();
        Map<String, Object> map = new HashMap<>();
        map.put("ret", 1);
        map.put("studentList", studentList);
        return map;
    }

    @Override
    public Map<String, Object> findById(Integer id) {
        Student2 student = student2Mapper.findById(id);
        Map<String, Object> map = new HashMap<>();
        map.put("ret", 1);
        map.put("student", student);
        return map;
    }

    @Override
    public Map<String, Object> add(Student2 student2) {
        student2Mapper.add(student2);
        Map<String, Object> map = new HashMap<>();
        map.put("ret", 1);
        map.put("msg", "添加学生成功");
        return map;
    }
}
